// nullable values should be checked explicitly against null or undefined
function getNum(): number | undefined {
  return undefined;
}

const num: number | undefined = getNum();
if (num) {
  console.log('num is defined');
}

function getStr(): string | null {
  return 'null';
}

const str: string | null = getStr();
if (str) {
  console.log('str is not empty');
}

<T extends null | undefined>(x: T) => x ? 1 : 0;
<T extends null>(x: T) => x ? 1 : 0;
<T extends undefined>(x: T) => x ? 1 : 0;

declare const x: symbol; if (x) {}
<T extends object>(x: T) => x ? 1 : 0;
<T extends Object | Function>(x: T) => x ? 1 : 0;
<T extends { a: number }>(x: T) => x ? 1 : 0;
<T extends () => void>(x: T) => x ? 1 : 0;
